
// 定义计分板类score
class ScorePanel {
    score = 0;
    level = 1;
    scoreEle: HTMLElement;
    levelEle: HTMLElement;
    maxLevel: number; // 最大等级
    levelSkip: number; // 升级需要分数
    constructor(maxLevel: number = 10, levelSkip: number = 10) {
        this.scoreEle = document.getElementById('score')!
        this.levelEle = document.getElementById('level')!
        this.maxLevel = maxLevel
        this.levelSkip = levelSkip
    }
    // 增加分数
    addScore() {
        this.scoreEle.innerHTML = ++this.score + ''
        if (this.score % this.levelSkip === 0) {
            this.levelUp()
        }
    }
    // 提升等级
    levelUp() {
        if (this.level < this.maxLevel) {
            this.levelEle.innerHTML = ++this.level + ''
        }
    }
}

export default ScorePanel